<html>

<head>
    <meta charset="utf-8">
    <meta name="author" content="Ajj">
    <title>轮播图</title>
    <script src="jquery-3.1.1.js"></script>
    <style>
        ul,
        li {
            margin: 0;
            padding: 0;
            list-style-type: none;
            /*position: relative;*/
        }
        
        #box {
            width: 520px;
            height: 280px;
            margin: 100 auto;
            position: relative;
        }
        
        #box .list li {
            position: absolute;
            top: 0;
            left: 0;
            display: none;
        }
        
        #box .list li.current {
            display: block;
        }
        
        #box .count {
            position: absolute;
            right: 10px;
            bottom: 0;
        }
        
        #box .count li {
            float: left;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background-color: #fa0;
            text-align: center;
            line-height: 20px;
            margin-left: 10px;
            color: #fff;
            opacity: 0.8;
            cursor: pointer;
        }
        
        #box .count li.current {
            background-color: orangered;
            opacity: 1;
        }
    </style>
</head>

<body>
    <div id="box">
        <ul class="list">
            <li class="current"><img src="img/1.jpg" alt=""></li>
            <li><img src="img/2.jpg" alt=""></li>
            <li><img src="img/3.jpg" alt=""></li>
            <li><img src="img/4.jpg" alt=""></li>
            <li><img src="img/5.jpg" alt=""></li>
        </ul>
        <ul class="count">
            <li class="current">1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
        </ul>
    </div>
</body>

</html>
<script>
    var current=0;
    var timer=null;
    // 自动
    var index = 0;
    timer=setInterval(play, 1000);
    function play() {
        index++;
        if (index == 5) {
            index = 0;
        }
        $('#box .list li').eq(index).css('display', 'block');
        $('#box .list li').eq(index).siblings().css('display', 'none');
        current=index;
        console.log(current);
        $('.count li').eq(current).addClass('current').siblings().removeClass('current');
    };
    // 手动        
    $('.count li').each(function(index){
        $(this).mouseover(function(){
        $(this).index=index;
        current=index; 
        $('#box .list li').eq(index).css('display', 'block').siblings().css('display','none');
        $('.count li').removeClass('current');
        
        $(this).addClass('current').siblings().removeClass('current');
        
     });
    });
    $('#box').mouseover(function(){
        clearInterval(timer);
    });
    $('#box').mouseout(function(){
        timer=setInterval(play,1000);
    });

</script>